# $Id: PKGBUILD 184218 2013-05-03 23:40:33Z dreisner $
# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgname=bash-completion
pkgver=2.1
pkgrel=2
pkgdesc="Programmable completion for the bash shell"
arch=('any')
url="http://bash-completion.alioth.debian.org/"
license=('GPL')
depends=('bash')
options=('!emptydirs' '!makeflags')
source=(http://bash-completion.alioth.debian.org/files/${pkgname}-${pkgver}.tar.bz2)
md5sums=('4e2a9f11a4042a38ee79ddcd048e8b9e')

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr --sysconfdir=/etc
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install

# bash-completion is sourced in /etc/bash.bashrc so that non-bash shell don't source it
  rm "${pkgdir}/etc/profile.d/bash_completion.sh"

# remove Slackware's makepkg completion
  rm "${pkgdir}/usr/share/bash-completion/completions/makepkg"

# provided by networkmanager
  rm "${pkgdir}/usr/share/bash-completion/completions/nmcli"

# provided by util-linux
  rm "${pkgdir}/usr/share/bash-completion/completions/cal"
  rm "${pkgdir}/usr/share/bash-completion/completions/chsh"
  rm "${pkgdir}/usr/share/bash-completion/completions/dmesg"
  rm "${pkgdir}/usr/share/bash-completion/completions/eject"
  rm "${pkgdir}/usr/share/bash-completion/completions/hd"
  rm "${pkgdir}/usr/share/bash-completion/completions/hexdump"
  rm "${pkgdir}/usr/share/bash-completion/completions/hwclock"
  rm "${pkgdir}/usr/share/bash-completion/completions/ionice"
  rm "${pkgdir}/usr/share/bash-completion/completions/look"
  rm "${pkgdir}/usr/share/bash-completion/completions/ncal"
  rm "${pkgdir}/usr/share/bash-completion/completions/newgrp"
  rm "${pkgdir}/usr/share/bash-completion/completions/renice"
  rm "${pkgdir}/usr/share/bash-completion/completions/rtcwake"
  rm "${pkgdir}/usr/share/bash-completion/completions/su"
}
